package com.controller;

import com.entity.Page;
import com.entity.Preorder;
import com.entity.Result;
import com.mapper.PreorderMapper;
import com.service.PreorderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@SuppressWarnings({"all"})
@RestController
@CrossOrigin(origins = "*")
@RequestMapping("/preorder")
public class PreorderController {

    @Autowired
    private PreorderService preorderService;
//查询所有preorder数据的接口
    @GetMapping("/list")
    public Result getPreorderList()
    {
        try {
            return Result.success(preorderService.FindByPages());
        }catch (Exception e){
            return Result.error(e.getMessage());
        }
    }
//添加preorder数据的接口
    @PostMapping("/add")
    public Result savePreorder(Preorder preorder)
    {
        try {
            return Result.success(preorderService.savePreorder(preorder));
        }catch (Exception e){
            return Result.error(e.getMessage());
        }
    }
//删除preorder数据的接口
    @DeleteMapping("/del")
    public Result delPreorder(Preorder preorder)
    {
        try {
            return Result.success(preorderService.delPreorder(preorder));
        }catch (Exception e){
            return Result.error(e.getMessage());
        }
    }
//修改preorder数据的接口
    @PostMapping("/update")
    public Result updatePreorder(Preorder preorder)
    {
        try {
            return Result.success(preorderService.updatePreorder(preorder));
        }catch (Exception e){
            return Result.error(e.getMessage());
        }
    }

}
